/************web服务器 app.js***********/
//引入模块
const express = require('express')
//引入用户管理路由器模块
const userRouter = require('./router/manage/user.js')
//引入买家管理路由模块
const customerRouter = require('./router/manage/customer.js')
//引入商品管理路由模块
const commodityRouter = require('./router/manage/commodity.js')
//引入评论管理路由器模块
const reviewRouter = require('./router/manage/review.js')
//引入商品类别路由器模块
const commodityKindRouter = require('./router/commodity/commodity')

const pro = require('./router/pro.js');
const email = require('./router/components/email.js');
const cors = require('cors');
const upload = require('./router/components/upload.js');
const user = require('./router/components/user.js');
const finish = require('./router/components/finishorder.js');
const customer = require('./router/customer/customer.js');
const goodsRouter = require('./router/customer/goods.js');
const prodetails = require('./router/customer/prodetails.js');
const cart = require('./router/customer/cart.js');
const app = express();
app.listen(8000, () => {
    console.log('逛淘吧服务器启动成功，端口号：' + '8000');
})
app.use(cors());
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use('/goods', goodsRouter);
app.use('/stroll', pro, upload, email, user, finish, customer);
//用户管理
app.use('/user', userRouter)
//买家管理
app.use('/customer', customerRouter)
//商品管理
app.use('/commodity', commodityRouter)
//评论管理
app.use('/review', reviewRouter)
// 商品详情
app.use('/prodetails', prodetails)
// 购物车
app.use('/cart', cart);
// var server = require('express')();
// var http = require('http').Server(server);
// var io = require('socket.io')(http, {
//     cors: {
//         origin: '*'
//     }
// });
// http.listen(9999);
// io.on('connection', function (socket) {
//     socket.on('textmsg', function (data) {
//         if (/你好/.test(data)) {
//             socket.emit('textmsg', '亲，您好，在的，很高兴为您服务，请问有什么能帮您的吗？');
//         } else if (/发货/.test(data)) {
//             socket.emit('textmsg', '您放心，在您付款之后我们会第一时间为您安排发货，我们承诺在48小时内会把商品发出。');
//         } else if (/退货/.test(data)) {
//             socket.emit('textmsg', ' 宝，咱家店铺所有产品都有附带运费险的哦，如果宝贝到货不符合您的要求，本店产品均是7天内无理由可以直接申请退换货的哈~');
//         } else if (/到货/.test(data)) {
//             socket.emit('textmsg', '宝子，一般是发货后1-3天左右到货，其他地区3-5天左右到货，具体到货时间根据快递送货时间为准哦')
//         } else {
//             socket.emit('textmsg', '听不懂');
//         }
//     })
// });
//商品类别查询
app.use('/commoditykind', commodityKindRouter)
